home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
4_0
/
VIVIDUS
/
VECT.SIT
/
vect
/
ifvect.c
next >
Wrap
C/C++ Source or Header
|
1991-10-05
|
4KB
|
253 lines
#include <math.h>
#include "vect.h"
/* ======================================================================
IntVector and FixedVector library.
This is part of the vect Vividus Source Code Library. See the
extern vect.doc documentation file for usage. See individual
routines for routine documentation.
Copyright 1991 by Vividus Consulting.
This is not public domain source code. You may not copy and
paste from this source code. Read your Vividus Licensing
agreement for details and other restrictions.
====================================================================== */
void
v2fv(
vector *v,
FixedVector *fv)
/*
fv = v
*/
{
#if __option(mc68881)
extended x, y, z;
x96tox80(&v->x, &x);
x96tox80(&v->y, &y);
x96tox80(&v->z, &z);
fv->x = X2Fix(x);
fv->y = X2Fix(y);
fv->z = X2Fix(z);
#else
extended x, y, z;
x96tox80(&v->x, &x);
x96tox80(&v->y, &y);
x96tox80(&v->z, &z);
fv->x = X2Fix(x);
fv->y = X2Fix(y);
fv->z = X2Fix(z);
#endif
}
void
fv2v(
FixedVector *fv,
vector *v)
/*
v = fv
*/
{
#if __option(mc68881)
extended x, y, z;
x = Fix2X(fv->x);
y = Fix2X(fv->y);
z = Fix2X(fv->z);
x80tox96(&x, &v->x);
x80tox96(&y, &v->y);
x80tox96(&z, &v->z);
#else
extended x, y, z;
x = Fix2X(fv->x);
y = Fix2X(fv->y);
z = Fix2X(fv->z);
x80tox96(&x, &v->x);
x80tox96(&y, &v->y);
x80tox96(&z, &v->z);
#endif
}
void
fv2iv (
FixedVector *fv,
IntVector *iv)
/*
iv = fv
*/
{
iv->x = HiWord(fv->x);
iv->y = HiWord(fv->y);
iv->z = HiWord(fv->z);
}
void
iv2fv (
IntVector *iv,
FixedVector *fv)
/*
fv = iv
*/
{
fv->x = Long2Fix((long) iv->x);
fv->y = Long2Fix((long) iv->y);
fv->z = Long2Fix((long) iv->z);
}
/* ============================================================ */
void
fvcopy (
FixedVector *v,
FixedVector *vo)
/*
vo = v
*/
{
vo->x = v->x;
vo->y = v->y;
vo->z = v->z;
}
void
fvscale (
Fixed scalar,
FixedVector *v,
FixedVector *vo)
/*
Multiply v by scalar.
*/
{
vo->x = FixMul(v->x, scalar);
vo->y = FixMul(v->y, scalar);
vo->z = FixMul(v->z, scalar);
}
void
fvvect (
FixedVector *a,
FixedVector *b,
FixedVector *v)
/*
Find the vector going from point a to point b.
*/
{
v->x = b->x - a->x;
v->y = b->y - a->y;
v->z = b->z - a->z;
}
void
fvsub (
FixedVector *a,
FixedVector *b,
FixedVector *v)
/*
v = a - b
*/
{
v->x = a->x - b->x;
v->y = a->y - b->y;
v->z = a->z - b->z;
}
void
fvadd (
FixedVector *a,
FixedVector *b,
FixedVector *v)
/*
v = a + b
*/
{
v->x = a->x + b->x;
v->y = a->y + b->y;
v->z = a->z + b->z;
return;
/* The following notice may not be removed under any
circumstance. See your licensing agreement. */
asm {
dc.b "ifvect Copyright 1991 Vividus Consulting"
}
}
/* ============================================================ */
void
ivcopy (
IntVector *v,
IntVector *vo)
/*
vo = v
*/
{
vo->x = v->x;
vo->y = v->y;
vo->z = v->z;
}
void
ivscale (
int scalar,
IntVector *v,
IntVector *vo)
/*
vo = scalar * v
*/
{
vo->x = v->x * scalar;
vo->y = v->y * scalar;
vo->z = v->z * scalar;
}
void
ivvect (
IntVector *a,
IntVector *b,
IntVector *v)
/*
Find the vector going from point a to point b.
*/
{
v->x = b->x - a->x;
v->y = b->y - a->y;
v->z = b->z - a->z;
}
void
ivsub (
IntVector *a,
IntVector *b,
IntVector *v)
/*
v = a - b
*/
{
v->x = a->x - b->x;
v->y = a->y - b->y;
v->z = a->z - b->z;
}
void
ivadd (
IntVector *a,
IntVector *b,
IntVector *v)
/*
v = a + b
*/
{
v->x = a->x + b->x;
v->y = a->y + b->y;
v->z = a->z + b->z;
}